package com.iss.demo.dao;

import com.iss.demo.entity.Order;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
@Mapper
@Repository
public interface OrderDao {
    @Select("SELECT * from `order`;")
    public List<Order> selectAll();

    @Select("SELECT * from `order` where u_id=#{u_id}")
    public List<Order> selectAllById(Integer u_id);

    @Insert("INSERT into `order`(c_name,c_dealer,c_fri_price,c_price,u_id,u_call,\n" +
            "u_name,u_phone,o_pay,o_time)  VALUES (#{c_name},#{c_dealer},#{c_fri_price}," +
            "#{c_price},#{u_id},#{u_call},#{u_name},#{u_phone},#{o_pay},CURRENT_TIMESTAMP);")
    public Integer insertOrder(Order order);

    @Delete("delete from `order` where o_id=#{o_id}")
    public Integer deleteOne(Integer o_id);

    @Update("UPDATE `order` set u_status = '已确认' where o_id = #{o_id}")
    public Integer updateShopCar(Integer o_id);
}
